home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / dbtable.dxr / 00045_PP Tables.ls < prev    next >
Encoding:
Text File  |  2000-01-18  |  3.6 KB  |  123 lines

  1. global gPPTableVarObj
  2.  
  3. on PPTables xFile
  4.   if voidp(xFile) then
  5.     alert("the parameter must be a string, with quotes")
  6.     exit
  7.   end if
  8.   StartMember = the number of member "pptable1" of castLib 1
  9.   InitPPVars(StartMember)
  10.   FormatFile = xFile & ".for"
  11.   FormatText = readFile(GetTextFilePath() & FormatFile)
  12.   LineText = line 1 of FormatText
  13.   xItems = integer(LineText)
  14.   ObjList = []
  15.   xMember = StartMember
  16.   repeat with rc = 1 to xItems
  17.     DataFile = RemoveSpaces(item rc of LineText)
  18.     append(ObjList, new(script("PP Table parent"), xMember, xFile & ".td" & rc, FormatFile))
  19.     xMember = xMember + 1
  20.   end repeat
  21.   SetTableList(gPPTableVarObj, ObjList)
  22.   CompileLinkList(FormatText)
  23.   ParseIfNotSpan()
  24.   ParseSpanWidths()
  25.   FinalizeSize()
  26.   ReadHeaderAndFootNotes(xFile, StartMember)
  27.   updateStage()
  28.   PPAlertFinished()
  29. end
  30.  
  31. on ParseIfNotSpan
  32.   TableList = GetTableObj(gPPTableVarObj)
  33.   LinkList = GetLinkList(gPPTableVarObj)
  34.   PenultimateList = getAt(LinkList, count(LinkList) - 1)
  35.   LastList = getAt(LinkList, count(LinkList))
  36.   if getAt(LastList, 1) > 1 then
  37.     BottomTableColCount = count(PenultimateList) + count(LastList)
  38.   else
  39.     BottomTableColCount = count(LastList)
  40.   end if
  41.   OrigWhichTables = CreateLookUpList(LinkList)
  42.   repeat with ColNum = 1 to BottomTableColCount
  43.     WhichTables = duplicate(OrigWhichTables)
  44.     if getAt(LastList, 1) > 1 then
  45.       if ColNum <= count(PenultimateList) then
  46.         position = count(LinkList)
  47.       else
  48.         position = count(LinkList) - 1
  49.       end if
  50.       deleteAt(WhichTables, position)
  51.     end if
  52.     SetMaxColumn(WhichTables, ColNum)
  53.   end repeat
  54. end
  55.  
  56. on SetMaxColumn WhichTables, mColNum
  57.   TableObjL = GetTableObj(gPPTableVarObj)
  58.   LinkList = GetLinkList(gPPTableVarObj)
  59.   ColNum = mColNum
  60.   NonSpanWidthList = []
  61.   columnList = [0, 0, 0, 0, 0, 0]
  62.   MaxList = count(WhichTables)
  63.   repeat with rc = MaxList down to 1
  64.     TableNum = getAt(WhichTables, rc)
  65.     TableList = getAt(LinkList, TableNum)
  66.     valuePosition = getPos(TableList, ColNum)
  67.     if valuePosition > 0 then
  68.       tempCol = valuePosition
  69.     else
  70.       exit repeat
  71.     end if
  72.     append(NonSpanWidthList, GetObjColWidth(getAt(TableObjL, TableNum), tempCol))
  73.     setAt(columnList, TableNum, tempCol)
  74.   end repeat
  75.   MaxWidth = max(NonSpanWidthList)
  76.   repeat with ti = 1 to count(TableObjL)
  77.     ColNum = getAt(columnList, ti)
  78.     if ColNum > 0 then
  79.       SetObjColWidth(getAt(TableObjL, ti), ColNum, MaxWidth)
  80.     end if
  81.   end repeat
  82. end
  83.  
  84. on FinalizeSize
  85.   TableList = GetTableObj(gPPTableVarObj)
  86.   LinkList = GetLinkList(gPPTableVarObj)
  87.   LastList = getAt(LinkList, count(LinkList))
  88.   repeat with rc in TableList
  89.     ObjAllColumnWidths(rc)
  90.   end repeat
  91.   if getAt(LastList, 1) > 1 then
  92.     HeightList = GetRowHeightList(getAt(TableList, count(TableList)))
  93.     if count(HeightList) > 0 then
  94.       ObjSetRowHeight(getAt(TableList, count(TableList) - 1), HeightList)
  95.     end if
  96.   end if
  97. end
  98.  
  99. on CompileLinkList FormatText
  100.   LinkList = []
  101.   StartLine = 2
  102.   EndLine = the number of lines in FormatText - 1
  103.   repeat with rc = StartLine to EndLine
  104.     append(LinkList, value(line rc of FormatText))
  105.   end repeat
  106.   SetLinkList(gPPTableVarObj, LinkList)
  107. end
  108.  
  109. on InitPPVars StartMember
  110.   gPPTableVarObj = new(script("PP Var Stuff"))
  111.   repeat with rc = StartMember to StartMember + 5
  112.     member(rc).tableData = []
  113.     member(rc).rowCount = 1
  114.     member(rc).columnCount = 1
  115.   end repeat
  116.   the itemDelimiter = ","
  117. end
  118.  
  119. on ReadHeaderAndFootNotes xFile, StartMember
  120.   set the text of field (StartMember + 6) to readFile(GetTextFilePath() & xFile & ".hd")
  121.   set the text of field (StartMember + 7) to readFile(GetTextFilePath() & xFile & ".fn")
  122. end
  123.